package com.kotlin.demo.类

class 解构操作 {

}

/**
 * 一般类 如果有需要可以手动解构
 */
class StudentDemo(val name: String, val age: String, val gender: Byte){

    operator fun component1() = name
    operator fun component2() = age
    operator fun component3() = gender

}


/**
 * 数据类 自动解构
 */
data class StudentDemo1(val name: String, val age: String, val gender: Byte)



fun main() {

    val(name,age,gender) = StudentDemo("zq","12",6)
    println("name:$name age:$age gender:$gender")

    val(name1,age1,gender1) = StudentDemo1("lucy", "34", 2)
    println("name:$name1 age:$age1 gender:$gender1")

    val(_,age2,_) = StudentDemo1("lucy", "34", 2)
    println("age2$age2")



}